package com.liu.domain.entity.search;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * @author liuxinghong
 * @Description: 索引库映射
 * @date 2019/8/2 000217:13
 */
@Data
@Document(indexName = "liuxinghong", type = "SearchMappingModel")
public class SearchMappingModel implements Serializable {

    @Id
    @NotNull(message = "索引字段id不能为空！")
    private String id;
    /**
     * 是否索引（index）：就是看该域是否能被搜索  表示使用分词索引
     * 是否分词：表示索引(analyzer)和搜索(searchAnalyzer)时都采用分词模式"ik_max_word" 来进行（会将文本做最细粒度的拆分）
     * 是否存储：就是是否在页面上显示
     */
    @Field(index = FieldIndex.analyzed , analyzer = "ik_max_word",searchAnalyzer = "ik_max_word",type = FieldType.String)
    @NotNull(message = "索引字段name不能为空！")
    private String name;

    /**
     * 是否索引：就是看该域是否能被搜索
     * 是否分词：表示在索引和搜索时都采用分词模型为 "ik_smart"(会做最粗粒度的拆分)
     * 是否存储：就是是否在页面上显示
     */
    @Field(index = FieldIndex.analyzed , analyzer = "ik_smart",searchAnalyzer = "ik_smart",type = FieldType.String)
    @NotNull(message = "索引字段keyWord不能为空！")
    private String keyWord;
    /**
     * 是否索引：就是看该域是否能被搜索
     * 是否分词：表示在索引和搜索时都采用分词模型为 "ik_smart"(会做最粗粒度的拆分)
     * 是否存储：就是是否在页面上显示
     */
    @Field(index = FieldIndex.analyzed , analyzer = "ik_smart",searchAnalyzer = "ik_smart",type = FieldType.String)
    @NotNull(message = "索引字段email不能为空！")
    private String email;

    @NotNull(message = "索引字段content不能为空！")
    @Field(index = FieldIndex.analyzed , analyzer = "ik_max_word",searchAnalyzer = "ik_smart",type = FieldType.String)
    private String content;
}
